package com.kws.merchant.controller;


import com.kws.merchant.domain.ItemPlan;
import com.kws.merchant.domain.po.ItemPlanPo;
import com.kws.merchant.domain.po.ItemPo;
import com.kws.merchant.domain.vo.ItemPlanDetailVo;
import com.kws.merchant.domain.vo.ItemPlanStageVo;
import com.kws.merchant.service.ItemPlanService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.web.bind.annotation.*;
import com.kws.common.core.domain.R;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.web.multipart.MultipartFile;

/**
 * 报价-项目进度(ItemPlan)表控制层
 *
 * @author yxy
 * @since 2024-10-24 14:47:00
 */
@RestController
@Api(tags = "报价-项目进度(ItemPlan)")
@RequestMapping("itemPlan")
public class ItemPlanController {
    /**
     * 服务对象
     */
    @Resource
    private ItemPlanService itemPlanService;

    @PostMapping("/page")
    @ApiOperation(value = "分页查询列表")
    public R<Page<ItemPlan>> pageList(@RequestBody ItemPo itemPo) {
        return R.ok(itemPlanService.pageList(itemPo));
    }
    @GetMapping("/detailById/{id}")
    @ApiOperation(value = "查看")
    public R<List<ItemPlanDetailVo>> detailById(@PathVariable Long id) {
        return R.ok(itemPlanService.detailById(id));
    }


    @PostMapping("/add")
    @ApiOperation(value = "新增数据")
    public R add(@RequestBody ItemPlan itemPlan) {
        itemPlan.setStatus(0);
        return R.ok(itemPlanService.save(itemPlan));
    }

    @GetMapping("itemStage/{id}")
    @ApiOperation("项目阶段")
    public R<ArrayList<ItemPlanStageVo>> itemStage(@PathVariable Long id){
        return R.ok(itemPlanService.itemStage(id));
    }

    @PostMapping("/upload")
    @ApiOperation(value = "项目进度文件上传")
    public R upload(ItemPlanPo itemPlanPo) {
        return R.ok(itemPlanService.upload(itemPlanPo));
    }
/*
    @PostMapping("/update")
    @ApiOperation(value = "修改数据")
    public R update(@RequestBody ItemPlan itemPlan) {
        return R.ok(itemPlanService.updateById(itemPlan));
    }*/


    @GetMapping("/deleteByPlanFile/{id}")
    @ApiOperation(value = "根据项目文件id删除进度文件")
    public R deleteByPlanFile(@PathVariable Long id) {
        return R.ok(itemPlanService.deleteByPlanFile(id));
    }
}
